package com.yzk.auction.dao;

import com.yzk.auction.entity.Bidding;
import com.yzk.auction.utils.JDBCUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.List;

public class BiddingDao {

    /**
     * 显示全部竞拍
     * */
    public static List<Bidding> query(int id){
        DataSource dataSource = JDBCUtils.getDataSource();
        QueryRunner qr = new QueryRunner(dataSource);
        List<Bidding> list = null ;
        try {
            list = qr.query("select * from tb_bidding where goods_id="+id+" ORDER BY bidding_price DESC;",
                    new BeanListHandler<>(Bidding.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;
    }

}
